<?php
	require_once '../lib/controller.php';

	class action extends controller
	{
		function do_get()
		{
			$data = array();
			$site = $this->module('biz.site');
			$site->page_size = 40;
			$data['site_list'] = $site->list_site();
			$data['url'] = isset( $this->get['url'] ) ? $this->get['url'] : '';

			$db = $this->module('lib.db');

			//本周内
			$day7 = strtotime( date( 'Y-m-d', strtotime("-7 day") ) . ' 00:00:00' );
			$sql = 'select count(1) cnt,b.id,b.title,b.url from meye_article_visit_log a inner join meye_article b on a.article_id=b.id where a.ctime>= ' . $day7 . ' group by a.article_id  order by cnt desc limit 0,60';
			$data['currweek_data'] = $db->query($sql);

			//上周内
			$day14 = strtotime( date( 'Y-m-d', strtotime("-14 day") ) . ' 00:00:00' );
			$sql = 'select count(1) cnt,b.id,b.title,b.url from meye_article_visit_log a inner join meye_article b on a.article_id=b.id where a.ctime>= ' . $day14 . ' group by a.article_id  order by cnt desc limit 0,30';
			$data['lastweek_data'] = $db->query($sql);

			//上月内
			$day30 =  strtotime( date( 'Y-m-d', strtotime("-30 day") ) . ' 00:00:00' );
			$sql = 'select count(1) cnt,b.id,b.title,b.url from meye_article_visit_log a inner join meye_article b on a.article_id=b.id where a.ctime>= ' . $day30 . ' group by a.article_id  order by cnt desc limit 0,30';
			$data['lastmonth_data'] = $db->query($sql);

			$this->view('www.site', $data);
		}

	}

	$action = new action();
	$action->run();
?>